<template>
  <view class="container" style="padding-bottom: 100px" v-if="isLoaded">
    <view class="content" style="padding: 20rpx 40rpx 180rpx; background-color: #fff">
      <li-form>
        <li-form-item label="名称" required>
          <li-input v-model="form.name" rule="trim" prop="name" v-on:blur="onBlurEvent($event)" />
        </li-form-item>
      </li-form>
    </view>

    <li-bottom-btns :mode="mode" v-on:btnDelClick="btnDelClick" v-on:btnEditOrSaveSubmitClick="btnEditOrSaveSubmitClick" />
  </view>
</template>
<script>
import liFormMixin from '../../../mixins/liFormMixin';
import { AddSysOrganization, DelSysOrganizationById, EditSysOrganization, GetSysOrganizationById } from '../../../common/modules/business.js';

import { transferTypeEnum } from '../../../common/dataTransfer.js';
import { checkerType, modeEnum, booleanEnum } from '../../../constants/normalConstants.js';
import { corpId, storeId } from '../../../constants/apiConstants.js';
export default {
  mixins: [liFormMixin],
  async onLoad(options) {
    this.loadEvent(options, this);
  },

  async mounted() {
    this.mountedEvent(this, {
      name: ''
    });
  },
  data() {
    return {
      modeEnum,
      booleanEnum,
      subject: '组织机构',
      rootRoute: 'workbench',
      routeName: 'institution',
      mode: 'add',
      isLoaded: false,
      id: null,
      form: null,

      transferRules: [
        /*   {
            name: "depositMoney",
            type: transferTypeEnum.float,
          },
       */
      ],
      rules: [
        {
          name: 'name',
          checkType: checkerType.endNotNull,
          errorMsg: '名字不能为空'
        }
      ],
      lock: false,

      DepartmentList: []
      /* 额外校验规则 */

      /* 额外转换器 */
    };
  },

  methods: {
    onBlurEvent(e) {
      this.formBlur(e, this);
    },

    async getData() {
      this.form = (await GetSysOrganizationById(this.id)).data.model;
    },

    async getOtherData() {
      // ..
    },

    async insertData() {
      return AddSysOrganization(this.form);
    },

    async delData() {
      return await DelSysOrganizationById(this.id);
    },

    async editData() {
      return await EditSysOrganization(this.form);
    },

    async btnDelClick() {
      await this.formDelete(this);
    },

    async btnEditOrSaveSubmitClick() {
      await this.formInsertOrEdit(this);
    }

    /* 额外方法放下面，上面是主干方法 */

    //方法放上面
  }
};
</script>
<style lang="scss" scoped>
@import '~@/static/styles/commonStyle.scss';
</style>
